add bablformats that match the hosts endianness
authorØyvind Kolås <pippin@gimp.org>
Sat, 17 Mar 2012 23:54:49 +0000 (23:54 +0000)
committerØyvind Kolås <pippin@gimp.org>
Sat, 17 Mar 2012 23:55:32 +0000 (23:55 +0000)
extensions/Makefile.am
extensions/cairo.c [new file with mode: 0644]

index e8ad11154d66a9d2d8faa266db2351f1212f20ae..fac012330d53c255d5010ba829e5ba3fe4cdba74 100644 (file)
@@ -14,6 +14,7 @@ AM_CPPFLAGS = \
 
 extdir = $(libdir)/babl-@BABL_API_VERSION@
 ext_LTLIBRARIES = \
+       cairo.la        \
        CIE.la          \
        gegl-fixups.la  \
        gggl-lies.la    \
@@ -22,6 +23,7 @@ ext_LTLIBRARIES = \
        naive-CMYK.la   \
        sse-fixups.la
 
+cairo_la_SOURCES = cairo.c
 CIE_la_SOURCES = CIE.c
 gegl_fixups_la_SOURCES = gegl-fixups.c
 gggl_lies_la_SOURCES = gggl-lies.c
diff --git a/extensions/cairo.c b/extensions/cairo.c
new file mode 100644 (file)
index 0000000..3a0732f
--- /dev/null
@@ -0,0 +1,86 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2012 Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdlib.h>
+#include "babl.h"
+
+int init (void);
+
+int
+init (void)
+{
+  int   testint  = 23;
+  char *testchar = (char*) &testint;
+  int   littleendian = (testchar[0] == 23);
+
+  if (littleendian)
+    {
+      babl_format_new (
+        "name", "cairo-ARGB32",
+        babl_model ("R'aG'aB'aA"),
+        babl_type ("u8"),
+        babl_component ("B'a"),
+        babl_component ("G'a"),
+        babl_component ("R'a"),
+        babl_component ("A"),
+        NULL
+      );
+
+      babl_format_new (
+        "name", "cairo-RGB24",
+        babl_model ("R'G'B'"),
+        babl_type ("u8"),
+        babl_component ("B'"),
+        babl_component ("G'"),
+        babl_component ("R'"),
+        babl_component ("PAD"),
+        NULL
+      );
+    }
+  else
+    {
+      babl_format_new (
+        "name", "cairo-ARGB32",
+        babl_model ("R'G'B'A"),
+        babl_type ("u8"),
+        babl_component ("A"),
+        babl_component ("R'a"),
+        babl_component ("G'a"),
+        babl_component ("B'a"),
+        NULL
+      );
+      babl_format_new (
+        "name", "cairo-RGB24",
+        babl_model ("R'G'B'"),
+        babl_type ("u8"),
+        babl_component ("PAD"),
+        babl_component ("R'"),
+        babl_component ("G'"),
+        babl_component ("B'"),
+        NULL
+      );
+    }
+  babl_format_new (
+    "name", "cairo-A8",
+    babl_model ("YA"),
+    babl_type ("u8"),
+    babl_component ("A"),
+    NULL
+  );
+  return 0;
+}